package com.lx.rabbitmq;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import utils.ConnectionUtils;

public class Sender {
	private static final String EXCHANGE_NAME = "exchange_route";
	public static void main(String[] args) throws Exception {
		Connection connection = ConnectionUtils.getMQConnection();
		Channel channel = connection.createChannel();
		
		//声明交换机
		channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.DIRECT);
		//路由键
		String routingKey = "error";
		
		//发送消息的时候指定路由键
		channel.basicPublish(EXCHANGE_NAME,routingKey, null, "Hello".getBytes());
		
		String routingKey2 = "info";
		channel.basicPublish(EXCHANGE_NAME,routingKey2, null, "Hello2".getBytes());
	}
}
